package ru.tusur.asu.utils;

import static java.lang.Math.min;
import static java.lang.Math.max;

public class MathUtils {
	
	public static int ceil4(int value) { 
		value += 3;
		return value - (value & 3);
	}
	
	public static float clamp(float value, float minValue, float maxValue) {
		return max(minValue, min(value, maxValue));
	}
	
	public static float dot(float[] v1, int v1Pos, float[] v2, int v2Pos, int length) {
		float result = 0;
		for (int i = 0; i < length; i++) {
			result += v1[v1Pos++] * v2[v2Pos++];
		}
		return result;
	}
}
